#include <tsin/display/TextArea.hpp>
#include <tsin/display/Font.hpp>
#include <tsin/display/Display.hpp>

#include <tsin/util/Logger.hpp>

#include <cstdio>
#include <cstdarg>

using namespace tsin;

TextArea::TextArea()
{
}

void TextArea::printf(Font *font, const char *fmt, ...)
{
        char buf[100];
        va_list ap;
        va_start(ap, fmt);
        vsnprintf(buf, 100, fmt, ap);

        float x = this->x, y = this->y;
        float w = font->w();
        char *c = buf;
        while (*c != '\0') {
                font->print(*c, x, y, zNear, Display::HORIZONTAL_LEFT | Display::VERTICAL_BOTTOM);

                x += w;
                c++;
        }

        va_end(ap);
}
